#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author:Zhangcl
import pymysql
import os
conn =pymysql.connect(host='192.168.4.239',port=3306,user='root',passwd='123456',db='mictic',charset="utf8")
cursor = conn.cursor()
f = open('60.txt','rb')
r = 0
file = open('wget_file','a')
for i in f:
    cc=i.decode().strip()
    #print(cc)
    sql = '''select concat(file_path,save_name) from mt_video where status = 1 and down_status = 0 and file_name = %s'''
    cursor.execute(sql,i.strip())
    row = cursor.fetchall()
    for d in row:
        for g in d:
            print(cc)
            print(g)
            print('/video/micro_ticket/dst'+g) #本地文件地址，可以用来按电影名查询ts文件
            b = g.split('/', 3)
            bm = b[1]+'/'
            c = os.path.join('/video/micro_ticket/dst/', bm,b[2])
            #print(c) #下载到本地路径的地址
            w=('http://117.27.142.78/Uploads/dst'+g)
            print(w)  #云端下载地址
            wf='wget -c %s'%w +' '+'-P %s' %c #下载地址
            print(wf)
            file.write(wf+'\n')
            r +=1
cursor.close()
conn.close()
f.close()
print(r)